#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
int main()
{
	int n;
	int a[100][100];
	int b[100] = { 0 };
	int c[100] = { 0 };
	int min = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			scanf("%d", &a[i][j]);
		}
	} 
	while (n)
	{
		if (n != 1)
		{
			printf("%d\n", a[1][1]);
		}
		if (n == 1)
		{
			printf("%d", a[0][0]);
			break;
		}
		for (int i = 0; i < n; i++)
		{
			min = a[i][0];
			for (int j = 1; j < n; j++)
			{
				if (min>a[i][j])
				{
					min = a[i][j];
				}
			}
			b[i] = min;
		}
		
		for (int j = 0; j < n; j++)
		{
			for (int i = 0; i < n; i++)
			{
				a[j][i] -= b[j];
			}
		}
		for (int i = 0; i < n; i++)
		{
			min = a[0][i];
			for (int j = 1; j < n; j++)
			{
				if (min > a[j][i])
				{
					min = a[j][i];
				}
			}
			c[i] = min;
		}
		for (int j = 0; j < n; j++)
		{
			for (int i = 0; i < n; i++)
			{
				a[i][j] -= c[j];
			}
		}
		if (n > 2)
		{
			for (int i = 1; i < n - 1; i++)
			{
				for (int j = 0; j < n; j++)
				{
					a[j][i] = a[j][i + 1];
				}
			}
			for (int i = 1; i < n - 1; i++)
			{
				for (int j = 0; j < n; j++)
				{
					a[i][j] = a[i + 1][j];
				}
			}
		}
		else if(n==2)
		{
			a[0][0] = a[1][1];
		}
  		n--;
	}
	return 0;
}